package com.xr.outside;

import java.util.Date;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.xr.common.CommUtil;

/**
 * inputBusinessStatDataViewModel
 */
public class inputBusinessStatDataViewModel extends DefaultViewModel {
  protected void initControls()
      throws Exception {
    super.initControls();
    // Add your code here
  }

  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds=getDataset("datasetBusinessStatData");
 
	  RecordIterator ri = ds.recordIterator();
	  ri.setVisibility(Dataset.FILTER_DELETED);
	  while (ri.hasNext()) {
	    Record r = ri.nextRecord();
	    dbs.setSql("delete from OT_BUSINESS_STAT where BUSINESS_STAT_ID="+r.getString("BUSINESS_STAT_ID"));
		  dbs.execute();
	  }
	  ds.moveFirst();
	  while(!ds.isLast()){
		  if(ds.getRecordState()==Record.STATE_NEW){
			  ds.setValue("CREATE_ID", CommUtil.getEmployeeId());
			  ds.setValue("CREATE_DATE", new Date());
		  }
		  if(ds.getRecordState()==Record.STATE_MODIFIED){
			  ds.setValue("MODIFY_ID", CommUtil.getEmployeeId());
			  ds.setValue("MODIFY_DATE", new Date());
		  }
	 
		  ds.moveNext();
	  }
	  CommUtil.dbsUpdateData(dbs, ds, "OT_BUSINESS_STAT", "BUSINESS_STAT_ID");
	  dbs.close();
   // super.doUpdateData(parameters, outParameters);
  }

}
